//
//  UserManager.m
//  KYProject
//
//  Created by Mxxx on 2016/12/21.
//  Copyright © 2016年 Roman. All rights reserved.
//

#import "UserManager.h"

@implementation UserManager
{
    NSMutableArray<DoctorApplyModel *> *_famousDoctorModelList;
}

#pragma mark
#pragma mark - 单例创建
static id _instance;
+(instancetype)sharedManager
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken,^
                  {
                      _instance = [[self alloc]init];
                  });
    return  _instance;
}

//懒加载famousDoctorModelList
- (NSMutableArray <DoctorApplyModel *>*)famousDoctorModelList
{
    if (!_famousDoctorModelList) {
        _famousDoctorModelList = [NSMutableArray array];
    }
    return _famousDoctorModelList;
}

//病例历史记录管理数组
//- (NSMutableArray<PresonMondel *> *)presonBingLIMDList
//{
//    if (!_presonBingLIMDList) {
//        _presonBingLIMDList = [[NSMutableArray alloc]init];
//    }
//    return _presonBingLIMDList;
//}
//注销用户
//- (void)cancellationUserInfo
//{
//    //创建文件管理对象
//    NSFileManager *manager = [NSFileManager defaultManager];
//    
//    //删除图片
//  [self.presonBingLIMDList enumerateObjectsUsingBlock:^(PresonMondel * _Nonnull model, NSUInteger idx, BOOL * _Nonnull stop) {
//      NSString *photoPath = model.imgPath;
//      [manager removeItemAtPath:photoPath error:nil];
//  }];
//    
//    //删除病例
//    NSString *casesPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).lastObject;
//    NSString *casesFilePath = [casesPath stringByAppendingPathComponent:self.userInfo.card_number.description];
//    [manager removeItemAtPath:casesFilePath error:nil];
//    
//    
//    //删除
//    NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES )lastObject]stringByAppendingPathComponent:@"userInfo.plist"];
//    [manager removeItemAtPath:filePath error:nil];
//    [[NSUserDefaults standardUserDefaults]removeObjectForKey:kIsUserLoginKey];
//}


//从沙盒去取出User信息
-(void)getUserInfoFromCache{
    
    NSString *Path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).lastObject;
    NSString *filePath = [Path stringByAppendingPathComponent:@"userInfo.plist"];
    
    self.userInfo = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
    
    //取出名名医申请数组
   // [self loadFamousDoctorModelList];
    //取出病例数组
  // [self loadCasesFromCache];
}

////从沙盒取出病例数组
//-(void)loadCasesFromCache{
//    
//    //先得到数组
//    NSString *Path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).lastObject;
//    NSString *filePath = [Path stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.plist",self.userInfo.card_number.description]];
//    
//    self.presonBingLIMDList = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
//    
//    //循环得到图片
////    [self.presonBingLIMDList enumerateObjectsUsingBlock:^(PresonMondel //* _Nonnull model, NSUInteger idx, BOOL * _Nonnull stop) {
//
//        NSString *cachePath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).lastObject;
//        NSString *imgName = model.imgPath;
//        NSString *filePath = [cachePath stringByAppendingPathComponent:imgName];
//        UIImage *photo = [UIImage imageWithContentsOfFile:filePath];
//        modfl.casesPhoto = photo;
//        NSLog(@"load   %@",filePath);
//    }];
//    
//}

//取出名医申请
//-(void)loadFamousDoctorModelList{
//    
//    NSString *Path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).lastObject;
//    NSString *filePath = [Path stringByAppendingPathComponent:self.userInfo.user_id.description];
//    
//    self.famousDoctorModelList = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
//    
//    
//}

@end
